uniform sampler2D defGeometry;
uniform sampler2D defExtend;
uniform sampler2D sphereTex;
varying vec2 texcoord0;
varying vec3 farRay;

void main()
{
    vec3 geo=texture2D(defGeometry,texcoord0).xyz;
	float reflection=texture2D(defExtend,texcoord0).b;
	vec3 pos=farRay*geo.z;
	vec3 nor=geo;
	nor.z=sqrt(1.0f-nor.x*nor.x-nor.y*nor.y);
	vec3 norTexcoord=normalize(reflect(pos,nor));
    norTexcoord=norTexcoord*0.5+0.5;
	gl_FragColor=texture2D(sphereTex,norTexcoord.xy);
}